import 'dart:convert' show json;

class SearchModel {

  String code;
  String message;
  SearchModelData data;

  SearchModel.fromParams({this.code, this.message, this.data});

  factory SearchModel(jsonStr) => jsonStr == null ? null : jsonStr is String ? new SearchModel.fromJson(json.decode(jsonStr)) : new SearchModel.fromJson(jsonStr);

  SearchModel.fromJson(jsonRes) {
    code = jsonRes['code'];
    message = jsonRes['message'];
    data = jsonRes['data'] == null ? null : new SearchModelData.fromJson(jsonRes['data']);
  }

  @override
  String toString() {
    return '{"code": ${code != null?'${json.encode(code)}':'null'},"message": ${message != null?'${json.encode(message)}':'null'},"data": $data}';
  }
}

class SearchModelData {

  int limit;
  int offset;
  int page;
  int total;
  String kw;
  List<SearchModelEntries> data;

  SearchModelData.fromParams({this.limit, this.offset, this.page, this.total, this.kw, this.data});

  SearchModelData.fromJson(jsonRes) {
    limit = jsonRes['limit'];
    offset = jsonRes['offset'];
    page = jsonRes['page'];
    total = jsonRes['total'];
    kw = jsonRes['kw'];
    data = jsonRes['data'] == null ? null : [];

    for (var dataItem in data == null ? [] : jsonRes['data']){
      data.add(dataItem == null ? null : new SearchModelEntries.fromJson(dataItem));
    }
  }

  @override
  String toString() {
    return '{"limit": $limit,"offset": $offset,"page": $page,"total": $total,"kw": ${kw != null?'${json.encode(kw)}':'null'},"data": $data}';
  }
}

class SearchModelEntries {

  var coupon_left;
  var coupon_money;
  var id;
  var qh_price;
  var volume;
  var zk_price;
  var fanli_money;
  var real_price;
  var sale_money;
  String clean_title;
  String coupon_end;
  String coupon_id;
  String coupon_info;
  String coupon_link;
  String coupon_start;
  String coupon_tkl;
  var coupon_total;
  String item_description;
  String item_url;
  String nick;
  var num_iid;
  String pict_url;
  var seller_id;
  String shop_title;
  String title;
  String tkl;
  List<dynamic> small_images;

  SearchModelEntries.fromParams({this.coupon_left, this.coupon_money, this.id, this.qh_price, this.volume, this.zk_price, this.fanli_money, this.real_price, this.sale_money, this.clean_title, this.coupon_end, this.coupon_id, this.coupon_info, this.coupon_link, this.coupon_start, this.coupon_tkl, this.coupon_total, this.item_description, this.item_url, this.nick, this.num_iid, this.pict_url, this.seller_id, this.shop_title, this.title, this.tkl, this.small_images});

  SearchModelEntries.fromJson(jsonRes) {
    coupon_left = jsonRes['coupon_left'];
    coupon_money = jsonRes['coupon_money'];
    id = jsonRes['id'];
    qh_price = jsonRes['qh_price'];
    volume = jsonRes['volume'];
    zk_price = jsonRes['zk_price'];
    fanli_money = jsonRes['fanli_money'];
    real_price = jsonRes['real_price'];
    sale_money = jsonRes['sale_money'];
    clean_title = jsonRes['clean_title'];
    coupon_end = jsonRes['coupon_end'];
    coupon_id = jsonRes['coupon_id'];
    coupon_info = jsonRes['coupon_info'];
    coupon_link = jsonRes['coupon_link'];
    coupon_start = jsonRes['coupon_start'];
    coupon_tkl = jsonRes['coupon_tkl'];
    coupon_total = jsonRes['coupon_total'];
    item_description = jsonRes['item_description'];
    item_url = jsonRes['item_url'];
    nick = jsonRes['nick'];
    num_iid = jsonRes['num_iid'];
    pict_url = jsonRes['pict_url'];
    seller_id = jsonRes['seller_id'];
    shop_title = jsonRes['shop_title'];
    title = jsonRes['title'];
    tkl = jsonRes['tkl'];
    small_images = jsonRes['small_images'] == null ? null : [];

    for (var small_imagesItem in small_images == null ? [] : jsonRes['small_images']){
      small_images.add(small_imagesItem);
    }
  }

  @override
  String toString() {
    return '{"coupon_left": $coupon_left,"coupon_money": $coupon_money,"id": $id,"qh_price": $qh_price,"volume": $volume,"zk_price": $zk_price,"fanli_money": $fanli_money,"real_price": $real_price,"sale_money": $sale_money,"clean_title": ${clean_title != null?'${json.encode(clean_title)}':'null'},"coupon_end": ${coupon_end != null?'${json.encode(coupon_end)}':'null'},"coupon_id": ${coupon_id != null?'${json.encode(coupon_id)}':'null'},"coupon_info": ${coupon_info != null?'${json.encode(coupon_info)}':'null'},"coupon_link": ${coupon_link != null?'${json.encode(coupon_link)}':'null'},"coupon_start": ${coupon_start != null?'${json.encode(coupon_start)}':'null'},"coupon_tkl": ${coupon_tkl != null?'${json.encode(coupon_tkl)}':'null'},"coupon_total": ${coupon_total != null?'${json.encode(coupon_total)}':'null'},"item_description": ${item_description != null?'${json.encode(item_description)}':'null'},"item_url": ${item_url != null?'${json.encode(item_url)}':'null'},"nick": ${nick != null?'${json.encode(nick)}':'null'},"num_iid": ${num_iid != null?'${json.encode(num_iid)}':'null'},"pict_url": ${pict_url != null?'${json.encode(pict_url)}':'null'},"seller_id": ${seller_id != null?'${json.encode(seller_id)}':'null'},"shop_title": ${shop_title != null?'${json.encode(shop_title)}':'null'},"title": ${title != null?'${json.encode(title)}':'null'},"tkl": ${tkl != null?'${json.encode(tkl)}':'null'},"small_images": $small_images}';
  }
}

